<%@ page contentType="text/html; charset=utf-8" %>

<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>

<form:form commandName="projectForm" target="tempFrame" id="projectForm" method="post" >
<table width="100%" border="0" cellpadding="0" cellspacing="3">
                        	
                          <tr>
                            <td width="114" height="20" class="globalText">项目编号(*)</td>
                            <td height="20" class="globalText">
                            	<input id="projectCode" type="text" class="txtbox required" size="20" name="projectCode" value="${project.code}"/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">项目名称(*)</td>
                            <td height="20" class="globalText">
                            	<input id="projectName" type="text" class="txtbox required" size="20" name="projectName" value="${project.name}" />
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">客户名称(*)</td>
                            <td height="20" class="globalText">
											<form:select path="customerIdSlt" cssClass="required">
							               		<form:option value="-1" label="-请选择-"/>
							               		<form:options items="${projectForm.customers}" itemValue="code" itemLabel="name" />
						               		</form:select>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">项目负责人(*)</td>
                            <td height="20" class="globalText">
                            	<input value="${project.managerEmpId}" type="hidden" name="projectManagerId" id="projectManagerId"/>
                            	<input   readonly="readonly" type="text" id="projectManagerPickedFrom" class="txtbox required" size="20" value="${manageName}" onclick="javascript:showRadioTree('<c:url value="/json/findAllOrgnizations.html"/>',this.id,setting);" />
                            </td>
                          </tr>
				                  
				                  
				                  
				           <tr>
                            <td width="114" height="20" class="globalText">开始时间(*)</td>
                            <td width="114" height="20" class="globalText">
				                    	<input onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}'})" type="text" readonly="readonly" class="txtbox required" size="20" id="startDate" name="startDate" value="<fmt:formatDate value="${project.startDate}" pattern="yyyy-MM-dd"/>"/>
                            </td>
				           </tr>
				           <tr>
                            <td width="114" height="20" class="globalText">结束时间(*)</td>
                            <td width="114" height="20" class="globalText">
				                    	<input onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'})" type="text" readonly="readonly" class="txtbox required" size="20" id="endDate" name="endDate" value="<fmt:formatDate value="${project.endDate}" pattern="yyyy-MM-dd"/>" />
                            </td>
				          </tr>
				                  
				                  
				                  
                          <tr>
                            <td width="114" height="20" class="globalText">项目类型(*)</td>
                            <td height="20" class="globalText">
															<form:select path="projectCategoryIdSlt" cssClass="required">
							               		<form:option value="-1" label="-请选择-"/>
							               		<form:options items="${projectForm.projectCategories}" itemValue="id" itemLabel="name" />
						               		</form:select>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">项目描述 </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText" colspan="2">
                            	<textarea class="globalText"  id="projectDescription" name="projectDescription" rows="5" cols="80">${project.description}</textarea>                   	
                            </td>
                          </tr>
                        </table>
                        
                        <div>
                        	<input onclick="javascript:window.history.back();" type="button" class="btnStyle" value=" 返回  ">
                        	<input type="button" name="saveBtn" class="btnStyle" value="  提交项目  ">
                        </div>
                        
                        
                        
                        <input type="hidden" name="updatekey" value="${project.id}" />
</form:form>


<script type="text/javascript">
<!--
$(document).ready(function() {
	
	
	
    var projectForm = $("form[id=projectForm]");
    var saveBtn = projectForm.find(":button[name=saveBtn]");
    
    projectForm.attr("action","<c:url value='editProject.html' />");
    saveBtn.click(function() {
    	if(projectForm.valid()){
    		projectForm.submit();
    	}
    });
    
    var validate=$("#projectForm").validate({
		showErrors: customShowErrors,
		onfocusout:false,
		onkeyup:false,
		onclick:false
	});
});

var setting = {
		view : {
			dblClickExpand : false
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			onDblClick:function(e, treeId, treeNode){
				if(!treeNode.isParent && !treeNode.isEmploy){
					var icon=treeNode.icon;
					treeNode.icon = "<c:url value='/css/zTreeStyle/img/loading.gif' />";
					$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					$.getJSON("<c:url value='/json/findAllChildEmployeesBy.html?orgCode=' />"+treeNode.id, function(jsonData){
						if(jsonData.length>0){
							var zTree = $.fn.zTree.getZTreeObj(treeId);
							for(var i=0;i<jsonData.length;i++){
								jsonData[i].isEmploy=true;
							}
							zTree.addNodes(treeNode, jsonData);
						}else{
							alert('未找到相关数据');
						}
						
						treeNode.icon = icon;
						$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					});
				}
			},
			onClick:function(e, treeId, treeNode){
				if(treeNode.isEmploy){
					var pickedFromObj = $('#projectManagerPickedFrom');
					pickedFromObj.attr('value', treeNode.name);
					$('#projectManagerId').val(treeNode.id);
				}
			}
		}
	};



function submitCallbackSuccess(obj){
	window.location="projectList.html";
}



//-->
</script>